package com.danielschon.triangularity.utility;

import android.util.FloatMath;
import android.util.Log;

public class Util {
	
	/**
	 *  Some basic utility functions
	 */
	
	public static float vecToRad(Vec v){
		try{
			return (float) Math.atan2(v.y, v.x);
		}catch(Exception e){
			Log.w("fail", e.getMessage());
			return 0;
		}
	}
	
	public static Vec radToVec(float i){
		try{
			return new Vec(FloatMath.cos(i), FloatMath.sin(i));
		}catch(Exception e){
			Log.w("fail", e.getMessage());
			return new Vec(0,0);
		}
	}
	
	public static float radToDeg(float f){
		return (float) (f * 57.2957795 );
	}	
	
	public static float degToRad(float f){
		return (float) (0.0174532925 * f);
	}
	
	public static float vecSpeed(Vec v){
		return (float) Math.sqrt(Math.pow(v.x, 2) + Math.pow(v.y, 2));
	}
}
